<?php

/**
 * @package Framework03
 * @author Daniel de Vries
 */

/**
 * Render a JSON file
 */
class JsonRenderDevice extends RenderDevice
{
	/**
	 * Initializes a new instance of this class.
	 * @param mixed $Data Could be anything except resources
	 */
	public function __construct($Data)
	{
		parent::__construct(array());
		$this->Data = $Data;
	}
	/**
	 * Gets the rendered content.
	 * @return string Returns a string with the parsed content.
	 */
	public function Render()
	{
		if (is_resource($this->Data))
			throw new Exception('Resources cannot be encoded to JSON');

		header('Content-type: text/x-json');
		echo json_encode($this->Data);
	}
}

?>